package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.mapper.ScoreMapper;
import com.example.demo.entity.Message;
import com.example.demo.entity.Score;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
public class GetAllScoreController {
    @Autowired
    private ScoreMapper sm;
    @RequestMapping("/getallscore")
    public void getAllScore(HttpServletResponse response, HttpServletRequest request) throws IOException {
        List<Score> list=new ArrayList<Score>();
        list=sm.findAllScore();
        response.getWriter().write(JSONObject.toJSONString(Message.success(list)));
    }
}
